package com.作业.Day21;

import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Homework1 {
    public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException, NoSuchMethodException, ClassNotFoundException, InvocationTargetException {
        //获取配置文件
        Properties properties = new Properties();
        //需要获取一个reader流
        FileReader fileReader = new FileReader("homework1/src/main/resources/Day21.properties");
        properties.load(fileReader);
        //获取值
        Object classname = properties.get("classname");
        Object methodname= properties.get("methodname");
        //获取类对象
        Class<?> aClass = Class.forName((String) classname);
        //通过方法名。获取方法
        Method declaredMethod = aClass.getDeclaredMethod((String) methodname);
        //调用方法
        declaredMethod.invoke(aClass.newInstance());

    }
}
